from PIL import Image
import numpy as np


def image_resize(image, new_size):
    padding_size = abs(image.shape[0] - image.shape[1]) // 2
    if image.shape[0] > image.shape[1]:
        pad = [(0, 0), (padding_size, padding_size)]
    else:
        pad = [(padding_size, padding_size), (0, 0)]
    image = np.lib.pad(image, pad, mode='constant', constant_values=255)
    return np.array(
        Image.fromarray(image).resize([new_size, new_size]))
